Skip to content

fix(provision): extend blueprint types with client-side cross-ref fields#30

Closed
pyramation wants to merge 1 commit intomainfrom
feat/provision-blueprint-ref-types
Closed

fix(provision): extend blueprint types with client-side cross-ref fields#30
pyramation wants to merge 1 commit intomainfrom
feat/provision-blueprint-ref-types

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

packages/provision declares tables, relations, and indexes using local ref / table_ref / source_ref / target_ref IDs so schemas can be written out-of-order. provisionBlueprint() then resolves these to table_name / source_table / target_table before sending the blueprint to construct_blueprint server-side.

node-type-registry@0.16.0 (pulled in as part of the PR #29 dep bump) no longer carries these client-side fields on BlueprintTable / BlueprintIndex / BlueprintRelation — they weren't part of the canonical server wire format. That caused ~260 TS2353/TS2339 errors across src/blueprint.ts and all 10 files under src/schemas/*, which broke the full pnpm build even though the CLI publish (PR #29) is now unblocked.

This PR fixes it entirely at the type level in a single filepackages/provision/src/blueprint.ts:

  • Re-export BlueprintTable as BaseBlueprintTable & { ref?: string }.
  • Re-export BlueprintIndex with table_name relaxed to optional and table_ref?: string added.
  • Distribute AddRelationRefs<T> over the BlueprintRelation union so every arm gains optional source_ref / target_ref while keeping source_table / target_table assignable.
  • Re-export BlueprintDefinition with those extended table/relation/index arrays.

Schemas already import from '../blueprint' (not node-type-registry directly), so zero caller changes — 10 schema files now type-check unchanged.

Also fixes 6 TS7018 implicit-any[] errors on the empty grant_roles / grants / policies / grant_privileges arrays inside the serverDef builder by annotating the map callback return type and array element types.

Full workspace pnpm build runs clean end-to-end (all 12 projects) after this patch.

Follow-up (separate PR, upstream)

The generated embedder in sdk/cli/generated/cli/embedder.ts that unblocked PR #29 should also be pushed upstream to the template at graphql/codegen/src/core/codegen/templates/embedder.ts in constructive-io/constructive — otherwise the next pnpm generate:all will regenerate the narrow Record<string, unknown> signatures and re-break publish. I have that change prepared locally on feat/auto-embed-generic-helpers in that repo; will open the PR after this one lands.

Review & Testing Checklist for Human

  • Run pnpm build at the repo root and confirm all 12 workspace projects compile (provision + 11 others).
  • Run pnpm -r test or at least the provision-adjacent tests to make sure the type relaxation didn't mask a real consumer bug.
  • Sanity-check one schema file (e.g. src/schemas/crm.ts) in your editor to confirm you still get IntelliSense on both ref (new) and the canonical BlueprintTable fields.
  • Before the next release, confirm that a real provisioning run still produces a valid construct_blueprint payload — the resolver in blueprint.ts (lines 122–159 in the new file) is unchanged, but worth a spot check that ref fields are correctly stripped/resolved into table_name / source_table / target_table on the wire.

Notes

  • No runtime behavior changes; this is type-only plus three as annotations on empty literals.
  • The AddRelationRefs<T> helper distributes correctly over the BlueprintRelation union because each arm satisfies { source_table: string; target_table: string } — including the RelationSpatial arm, whose required source_field / target_field pass through unchanged.
  • Keeping ref / table_ref / source_ref / target_ref as optional siblings rather than replacing the canonical names means schemas can freely mix both styles (already the case in spatial-relations.ts and cross-relations.ts).

Link to Devin session: https://app.devin.ai/sessions/fabecb6a46504fc293feca22d9cc91d4
Requested by: @pyramation

packages/provision declares tables, relations, and indexes using local
`ref` / `table_ref` / `source_ref` / `target_ref` IDs so schemas can
be written out-of-order; provisionBlueprint resolves these to
`table_name` / `source_table` / `target_table` before sending the
blueprint to construct_blueprint.

node-type-registry@0.16.0 no longer carries these client-side fields on
BlueprintTable / BlueprintIndex / BlueprintRelation. Extend the types
locally in blueprint.ts (and re-export under the canonical names) so
the 10 schema files and blueprint.ts itself type-check without touching
any caller or weakening the server wire format.

Also fixes TS7018 implicit-any[] errors on empty grant_roles / grants /
policies / grant_privileges arrays inside the serverDef builder.
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration
Copy link
Copy Markdown

Superseded by #32 (merged). Safe to close.

@pyramation pyramation closed this Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant